home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / eflibpt4.zip / DEMO / DATATYPE / LINKNEST.PAS < prev    next >
Pascal/Delphi Source File  |  1996-08-18  |  2KB  |  46 lines

  1. { Borland Pascal Extended Function Library - EFLIB (C) Johan Larsson, 1996
  2.   Demonstration of nested initialization of linked structures
  3.  
  4.   EFLIB IS PROTECTED BY THE COPYRIGHT LAW AND MAY NOT BE COPIED, SOLD OR
  5.   MANIPULATED. FOR MORE INFORMATION, SEE PROGRAM MANUAL! THIS DEMONSTRAT-
  6.   ION PROGRAM MAY FREELY BE USED AND DISTRIBUTED.                          }
  7.  
  8.  
  9. uses EFLIBDEF, EFLIBINI, EFLIBBAS, EFLIBDAT;
  10.  
  11.  
  12. const Data : array [1..5] of string = ('Entry one', 'Entry two', 'Entry three',
  13.              'Entry four', 'Entry five');
  14.  
  15. var MyList : LinkedListObjectType;
  16.  
  17.  
  18.  
  19. begin
  20.      with MyList do begin
  21.           { Initialize structure and chain some nodes }
  22.           InitializeChain (SizeOf(Data[1]),
  23.             New (GenericLinkageObjectPointerType, InitializeChain (Data[1], SizeOf(Data[1]),
  24.             New (GenericLinkageObjectPointerType, InitializeChain (Data[2], SizeOf(Data[2]),
  25.             New (GenericLinkageObjectPointerType, InitializeChain (Data[3], SizeOf(Data[3]),
  26.             New (GenericLinkageObjectPointerType, InitializeChain (Data[4], SizeOf(Data[4]),
  27.             New (GenericLinkageObjectPointerType, InitializeChain (Data[5], SizeOf(Data[5]), NIL)))))))))));
  28.  
  29.           { The complex initialization could be replaced with:
  30.                Initialize (SizeOf(Data[1]);
  31.                Add (Data[1]); Add (Data[2]);
  32.                Add (Data[3]); Add (Data[4]); Add (Data[5]); }
  33.  
  34.           { Display elements }
  35.           with CreateIterator^ do begin { Allocate iterator object }
  36.                repeat
  37.                      WriteLn (String(Content^));
  38.                      WalkForward; { Next element }
  39.                until IsEnd;
  40.                Free; { Iterator }
  41.           end;
  42.  
  43.           Intercept;
  44.      end;
  45.      if GlobalDataError then WriteLn ('Error(s) reported!');
  46. end.